<div style="text-align:center; margin: 20px 0;">
    <div id="{{ elem_id }}"></div>
</div>

{% block extra_js %}
<script>
layui.use(['laypage'], function () {
    const laypage = layui.laypage;

    laypage.render({
        elem: '{{ elem_id }}',
        count: parseInt("{{ count }}") || 0,
        limit: 10,
        curr: parseInt("{{ current_page }}") || 1,
        jump: function(obj, first) {
            if (!first) {
                const keyword = "{{ keyword }}";
                let url = `?page=${obj.curr}`;
                if (keyword) url += `&keyword=${encodeURIComponent(keyword)}`;
                location.href = url;
            }
        }
    });
});
</script>
{% endblock %}
